<?php
/**
 * Created by PhpStorm.
 * User: Eric
 * Email: 13522679763@163.com
 * Date: 2018/3/12
 * Time: 14:05
 */
namespace app\model;
use think\Model;
class Guarantee extends Model
{

    //获取列表
    function index(){
        $result=$this->where(array('status'=>1))->field('id,name')->order('sort desc')->select();
        if ($result) {
            $result = collection($result)->toArray();//对象转成数组
            return $result;
        } else {
            return;
        }
    }

    //添加
    function add($data)
    {
        $result = $this->isUpdate(false)->allowField(true)->insertGetId($data);
        if ($result) {
            return $result;
        } else {
            return false;
        }
    }

    //编辑  删除
    function edit($pa){
        $result = $this->isUpdate(true)->allowField(true)->save($pa);
        return $result;
    }

}